/*
 * FileName: using_base_base.cc
 * Author: 李波(Edwin Lee)
 * Date: 2024-09-07 17:54:30
 * Version: 1.0
 * Description: 派生类使用using base::base直接继承基类的构造函数
 */
#include <iostream>

using namespace std;

class Base
{
public:
	Base(){cout<< "call Base()"<<endl;}
	Base(int){cout<< "call Base(int)" << endl;}
	Base(int,int){cout << "call Base(int,int)" << endl;}
	~Base(){cout<<"call ~Base()"<<endl;}
};

class Deriver:public Base
{
public:
	// 继承基类构造函数
	using Base::Base;
	Deriver(){cout<<"call Deriver()"<<endl;}
	Deriver(int){cout<<"call Deriver(int)"<<endl;}
};

int main()
{
	//如果派生类存在此函数则基类触发Base(),派生类触发Deriver(int),如果派生类不存在此函数则,派生类构造函数不触发，直接调用基类的Base(int)
	Deriver d1(10);
	cout <<"----------------------------------------"<<endl;
	// 派生类没有Deriver(int,int)，因此直接触发Base(int,int)
	Deriver d2(10,20);
	return 0;
}
